home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17031 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  64 lines

  1. Path: news.iwl.net!usenet
  2. From: "Gary L. Grobe" <glgrobe@iwl.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: STL - is it remotly possible
  5. Date: Sat, 13 Apr 1996 00:59:59 -0500
  6. Organization: A poorly-installed InterNetNews site
  7. Message-ID: <316F42DF.42F4@iwl.net>
  8. NNTP-Posting-Host: p168.iwl.net
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win95; I)
  13.  
  14. I'm looking for help & suggestions. (Using STL's sequence containers).
  15. Is this even slightly correct. It was intended to be read as, create an element in the root 
  16. list(Library)that points to an object(BookCase) which contains several lists(the books). A 
  17. tree with many roots. Everything should be dynamic. Of course it doesn't work, but I think it 
  18. will give an idea of what I'm trying to accomplish.
  19. -----
  20. class Sci_Fi { 
  21.       int no;
  22.    public:
  23.       Sci_Fi *sci; /* ... */
  24. };
  25. class Western { 
  26.       int no;
  27.    public:
  28.       Western *west; /* ... */
  29. };
  30. class BookCase { /* same format as above */ };
  31. class Library { /* same format as above */ };
  32.  
  33. typedef list<Sci_Fi*> SFBooks[]; // to be contained in BookCases
  34. typedef list<Western*> WBooks[]; // to be contained in BookCases
  35. typedef list<Sci_Fi**, Western**> BookCases[]; to contain books
  36. typedef list<BookCases*> Library[]; // each elem of this lst -> to a bookcase
  37.  
  38. void creat_Lib(int no_sfb, int no_wb) {
  39.    SFBooks sfb(no_sfb);
  40.    Western wb(no_wb);
  41.    BookCases book_case;
  42.    Library lib;
  43.  
  44.    book_case.push_back(sfb);
  45.    book_case.push_back(wb);
  46.     
  47.    lib.push_back(book_case);    
  48. };
  49.  
  50. Sci_Fi::Sci_Fi(int n) {
  51.    sci = new Sci_Fi[n];    
  52. }
  53. Western::Western(int n) {
  54.    west = new Western[n];
  55. }
  56. BookCase::BookCase() {
  57.    bcase = new BookCase;
  58. }
  59. Library::Library() {
  60.    lbry = new Library;
  61. }
  62. -------
  63. Thanks in advance,
  64.